import { _decorator, Component, Node, Vec3, Enum } from "cc";
const { ccclass, property } = _decorator;

enum ROAD_POINT_TYPE {
    Normal = 1,
    Start,
    Greeting,
    GoodBye,
    End,
    AIStart,
}
Enum(ROAD_POINT_TYPE);

enum ROAD_MOVE_TYPE {
    Line = 1,
    Bend,
}
Enum(ROAD_MOVE_TYPE); // 序列化enum才能在cocos属性面板查看

@ccclass("RoadPoint")
export class RoadPoint extends Component {
    public static RoadPointType = ROAD_POINT_TYPE;
    public static RoadMoveType = ROAD_MOVE_TYPE;

    @property({
        type: ROAD_POINT_TYPE,
        displayOrder: 1,
    })
    type = ROAD_POINT_TYPE.Normal;

    @property({
        type: Node,
        displayOrder: 2,
        visible: function (this: RoadPoint) {
            return this.type !== ROAD_POINT_TYPE.End;
        },
    })
    nextStation: Node = null!;

    @property({
        type: ROAD_MOVE_TYPE,
        displayOrder: 3,
        visible: function (this: RoadPoint) {
            return this.type !== ROAD_POINT_TYPE.End;
        },
    })
    moveType = ROAD_MOVE_TYPE.Line;

    @property({
        displayOrder: 4,
        visible: function (this: RoadPoint) {
            return this.type !== ROAD_POINT_TYPE.End && this.moveType == ROAD_MOVE_TYPE.Bend;
        },
    })
    clockwise = true;

    @property({
        displayOrder: 5,
        visible: function (this: RoadPoint) {
            return this.type === ROAD_POINT_TYPE.Greeting || this.type === ROAD_POINT_TYPE.GoodBye;
        },
    })
    direction = new Vec3(1, 0, 0);

    @property({
        displayOrder: 6,
        visible: function (this: RoadPoint) {
            return this.type === ROAD_POINT_TYPE.AIStart;
        },
    })
    interval = 3;

    @property({
        displayOrder: 7,
        visible: function (this: RoadPoint) {
            return this.type === ROAD_POINT_TYPE.AIStart;
        },
    })
    delayTime = 0;

    @property({
        displayOrder: 8,
        visible: function (this: RoadPoint) {
            return this.type === ROAD_POINT_TYPE.AIStart;
        },
    })
    speed = 0.05;

    // 201,202
    @property({
        displayOrder: 9,
        visible: function (this: RoadPoint) {
            return this.type === ROAD_POINT_TYPE.AIStart;
        },
    })
    cars = "201";
}
